<?php
class FacultyController extends DRX_Controller 
{
    function get_profile_image_url($profile_image_path)
    {
        $list = explode("/",$profile_image_path);
        $filename = $list[count($list)-1];
        $url = PROFILE_IMAGE_URL . $list[count($list)-2] . "/$filename";
        return $url;
    }
    
	function pageAction()
	{
		global $arrArgs;
		$profile_id 	= $arrArgs[0];
		$profile = new Profile();
		$profileInfo = $profile->getProfileInfo($profile_id);
		if ($profileInfo->fetch())
		{
    		$profile_content  = $profileInfo->profile_content;
    		$profile_title    = $profileInfo->profile_title;
    		$profile_image1   = $profileInfo->profile_image1;
    		$profile_image2   = $profileInfo->profile_image2;
    		$profile_image3   = $profileInfo->profile_image3;
    		$profile_image1   = $this->get_profile_image_url($profile_image1);
    		$profile_image2   = $this->get_profile_image_url($profile_image2);
    		$profile_image3   = $this->get_profile_image_url($profile_image3);
		}
		else 
		{
		    redirect(APPLICATION_URL . FACULTY_URL);
		}
		$smarty 	= DRX::load("smarty");
		$smarty->assign('profile_content',$profile_content);
		$smarty->assign('profile_title',$profile_title);
		$smarty->assign('profile_image1',$profile_image1);
		$smarty->assign('profile_image2',$profile_image2);
		$smarty->assign('profile_image3',$profile_image3);
		$smarty->display("profile/profile.tpl");
	}
	
	function indexAction()
	{
		$smarty 	= DRX::load("smarty");
		
		$layout     = new Layout();
		$args['topmenu_id'] = FACULTY_ID;
		$layout->prepareLayout($args);
		
		$profile  = new Profile();
		$profile_list = $profile->getAllProfileList();
		$title    = PAGE_TITLE_FACULTY;
        $smarty->assign("title",$title);
		$smarty->assign("profile_list",$profile_list);
		$content  = $smarty->fetch("profile/home.tpl");
		$smarty->assign("content",$content);
			
		$smarty->display("solvay.tpl");
	}
}
?>